package com.cyy.defstep;

import com.cyy.service.HttpService;
import com.cyy.utils.Common;
import io.cucumber.datatable.DataTable;
import io.cucumber.java.zh_cn.当;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

public class HttpDefstep extends AbstractDefstep {
    @Autowired
    HttpService httpService;
    @Autowired
    Common common;

    @当("^发送一个订单$")
    public void create_order(DataTable table) {
        List<Map<Object, Object>> maps = common.datatableRep(table);
        Map<Object, Object> payload = maps.get(0);
        Response body = httpService.createOder(payload);
        assertThat(body.getBody().asString(), body.getStatusCode(), equalTo(200));
    }

}
